package com.ctvit.cch.web.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ctvit.cch.core.pojo.dto.creative.CreativeAuditApproveDTO;
import com.ctvit.cch.core.pojo.dto.creative.CreativeAuditRejectDTO;
import com.ctvit.cch.core.service.ICreativeAuditService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;

/**
 * 创意审批Controller
 *
 * @author heyingcheng
 * @date 2025/7/19
 */
@RestController
@RequestMapping("/creative/audit")
public class CreativeAuditController extends BaseController {

    private final ICreativeAuditService creativeAuditService;

    public CreativeAuditController(ICreativeAuditService creativeAuditService) {
        this.creativeAuditService = creativeAuditService;
    }

    /**
     * 审批通过创意选题
     *
     * @param dto 审批通过参数
     * @return {@link AjaxResult} 操作结果
     */
    @PreAuthorize("@ss.hasPermi('creative:audit:approve')")
    @PostMapping("/approve")
    public AjaxResult approve(@RequestBody @Validated CreativeAuditApproveDTO dto) {
        return toAjax(creativeAuditService.approve(dto));
    }

    /**
     * 审批驳回创意选题
     *
     * @param dto 审批驳回参数
     * @return {@link AjaxResult} 操作结果
     */
    @PreAuthorize("@ss.hasPermi('creative:audit:reject')")
    @PostMapping("/reject")
    public AjaxResult reject(@RequestBody @Validated CreativeAuditRejectDTO dto) {
        return toAjax(creativeAuditService.reject(dto));
    }

}